package mainSwingClass;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;

import java.awt.Dimension;
import java.util.ArrayList;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ScrollPaneConstants;
import javax.swing.JLabel;
import javax.swing.JSeparator;

import daoClass.DogDAO;
import voClass.DogVO;

public class DogMain2 extends JDialog {

	private final JPanel contentPanel = new JPanel();
	private JTable table;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			DogMain2 dialog = new DogMain2();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public DogMain2() {
		setTitle("강아지");
		setBounds(100, 100, 640, 480);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(new BorderLayout(0, 0));
		{
			JPanel panel = new JPanel();
			panel.setPreferredSize(new Dimension(120, 10));
			contentPanel.add(panel, BorderLayout.EAST);
			
			JLabel lblNewLabel = new JLabel("New label");
			lblNewLabel.setPreferredSize(new Dimension(100, 150));
			
			JSeparator separator = new JSeparator();
			separator.setPreferredSize(new Dimension(100, 50));
			
			JPanel panel_1 = new JPanel();
			panel_1.setPreferredSize(new Dimension(100, 150));
			GroupLayout gl_panel = new GroupLayout(panel);
			gl_panel.setHorizontalGroup(
				gl_panel.createParallelGroup(Alignment.LEADING)
					.addGroup(gl_panel.createSequentialGroup()
						.addContainerGap()
						.addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addContainerGap(8, Short.MAX_VALUE))
					.addComponent(separator, GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
					.addGroup(gl_panel.createSequentialGroup()
						.addComponent(panel_1, GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE)
						.addContainerGap())
			);
			gl_panel.setVerticalGroup(
				gl_panel.createParallelGroup(Alignment.LEADING)
					.addGroup(gl_panel.createSequentialGroup()
						.addContainerGap()
						.addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE, 102, GroupLayout.PREFERRED_SIZE)
						.addGap(18)
						.addComponent(separator, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
						.addPreferredGap(ComponentPlacement.RELATED, 33, Short.MAX_VALUE)
						.addComponent(panel_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
			);
			panel.setLayout(gl_panel);
		}
		{
			JPanel panel = new JPanel();
			panel.setPreferredSize(new Dimension(420, 10));
			contentPanel.add(panel, BorderLayout.WEST);
			panel.setLayout(new BorderLayout(0, 0));
			{
				JPanel panel_1 = new JPanel();
				panel.add(panel_1, BorderLayout.CENTER);
				panel_1.setLayout(new BorderLayout(0, 0));
				{
					JScrollPane scrollPane = new JScrollPane();
					scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
					panel_1.add(scrollPane, BorderLayout.CENTER);
					{
					DogDAO dg = new DogDAO();
					ArrayList<DogVO> dList = new ArrayList<>();
					// dList.add( new DogVO(id, dname, sex, type, age, regdate, collar, fno, specificloc, storeddept, etc, mercykilling);
					dList.addAll(dList);
					
					DefaultTableModel model = new DefaultTableModel();
					
					
					table = new JTable();
					table.setPreferredSize(new Dimension(350, 300));
					scrollPane.setViewportView(table);
					}
				}
			}
		}
		{
			JPanel panel = new JPanel();
			panel.setPreferredSize(new Dimension(10, 30));
			contentPanel.add(panel, BorderLayout.NORTH);
			
			JButton insertBtn = new JButton("추가");
			JButton updateBtn = new JButton("수정");
			JButton deleteBtn = new JButton("삭제");
			JButton selectBtn = new JButton("조회");
			GroupLayout gl_panel = new GroupLayout(panel);
			gl_panel.setHorizontalGroup(
				gl_panel.createParallelGroup(Alignment.LEADING)
					.addGroup(gl_panel.createSequentialGroup()
						.addGap(30)
						.addComponent(insertBtn, GroupLayout.PREFERRED_SIZE, 76, GroupLayout.PREFERRED_SIZE)
						.addGap(74)
						.addComponent(updateBtn, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
						.addPreferredGap(ComponentPlacement.RELATED, 89, Short.MAX_VALUE)
						.addComponent(deleteBtn, GroupLayout.PREFERRED_SIZE, 79, GroupLayout.PREFERRED_SIZE)
						.addGap(77)
						.addComponent(selectBtn, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE)
						.addGap(28))
			);
			gl_panel.setVerticalGroup(
				gl_panel.createParallelGroup(Alignment.TRAILING)
					.addGroup(Alignment.LEADING, gl_panel.createSequentialGroup()
						.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
							.addComponent(updateBtn)
							.addComponent(insertBtn)
							.addComponent(selectBtn)
							.addComponent(deleteBtn))
						.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
			);
			panel.setLayout(gl_panel);
		}
		{
			JPanel panel = new JPanel();
			panel.setPreferredSize(new Dimension(10, 30));
			contentPanel.add(panel, BorderLayout.SOUTH);
			
			JButton selectOnrBtn = new JButton("상세조회");
			GroupLayout gl_panel = new GroupLayout(panel);
			gl_panel.setHorizontalGroup(
				gl_panel.createParallelGroup(Alignment.LEADING)
					.addGroup(gl_panel.createSequentialGroup()
						.addGap(258)
						.addComponent(selectOnrBtn)
						.addContainerGap(259, Short.MAX_VALUE))
			);
			gl_panel.setVerticalGroup(
				gl_panel.createParallelGroup(Alignment.LEADING)
					.addGroup(gl_panel.createSequentialGroup()
						.addComponent(selectOnrBtn)
						.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
			);
			panel.setLayout(gl_panel);
		}
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton okBtn = new JButton("확인");
				okBtn.setActionCommand("OK");
				buttonPane.add(okBtn);
				getRootPane().setDefaultButton(okBtn);
			}
			{
				JButton backBtn = new JButton("돌아가기");
				backBtn.setActionCommand("Cancel");
				buttonPane.add(backBtn);
			}
		}
	}
}
